# ==========================================
# 2024 EExuke. All Rights Reserved.
# ==========================================

DIR_OBJ = ./obj
DIR_SRC = ./src
DIR_INC = ./inc

SRC = $(wildcard ${DIR_SRC}/*.cpp)
OBJ = $(patsubst %.cpp, ${DIR_OBJ}/%.o, $(notdir $(SRC)))

BIN_TARGET = my_gst

#CC = gcc
STRIP ?= strip
CFLAGS = -g -Wall -I$(DIR_INC) -I/usr/local/include/opencv4
LIB_CFLAGS += `pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0 gstreamer-rtsp-1.0 gstreamer-net-1.0 libcgroup`
LIB_CFLAGS += -L/usr/local/lib
LIB_CFLAGS += -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio

${BIN_TARGET}: ${OBJ}
	$(warning Building $(BIN_TARGET) ...)
	@$(CXX) $(OBJ) -o $@ ${LIB_CFLAGS}
	@$(STRIP) $@

${DIR_OBJ}/%.o: ${DIR_SRC}/%.cpp
	$(warning Comping $< ...)
	@$(CXX) $(CFLAGS) -c $< -o $@ ${LIB_CFLAGS}

# Prevent naming conflicts such as the existence of a file named clean.
.PHONY: clean

clean:
	$(warning Clean $(OBJ), $(BIN_TARGET) ...)
	@find ${DIR_OBJ} -name *.o -exec rm -rf {} \;
	@rm -rf $(BIN_TARGET)

